package body WriterTask is

   task body WT is

      Next_Period : Ada.Real_Time.Time;
      Period : constant Ada.Real_Time.Time_Span := Ada.Real_Time.Microseconds(Cycle_Time);
      LocalData : Data;

      package X_IO is new Ada.Text_IO.Integer_IO(Positive);
      use X_IO;

   begin
      -- Initialization code

      Next_Period := Ada.Real_Time.Clock + Ada.Real_Time.Microseconds(Cycle_Time);
      LocalData := 5;

      Ada.Text_IO.Put_Line("Activacao da Writer Task ");
      X_IO.Put(Item => Id, Width => 3, Base => 10);
      Ada.Text_IO.Put_Line("");

      loop

         delay until Next_Period; -- wait until next period after offset
                                  -- Non-suspending periodic response code
                                  -- May include calls to protected procedures

         PO.Shared_Data.Put(LocalData);

         Ada.Text_IO.Put("Writer Task ");
         X_IO.Put(Item => Id, Width => 3, Base => 10);
         Ada.Text_IO.Put("  -> Data = ");
         X_IO.Put(Item => Integer (LocalData), Width => 3, Base => 10);
         Ada.Text_IO.Put_Line("");

         Next_Period := Next_Period + Period;
         LocalData := LocalData + 1;

         end loop;
      end WT;
end WriterTask;
